#include "typedef.h"
#include "astraldef.h"
#include "timer.h"

void create_ttimer(AstralTickTimer timer, int timeout, executable callback, object arg)
{
    timer->timeout = timeout;
    timer->is_oneshot = True;
    timer->callback = callback;
    timer->arg = arg;
    static int timer_id = 0;
    timer->id = timer_id;
    timer_id++;
}

void set_ttimer_attribute(AstralTickTimer timer, boolean auto_reload, const char *name)
{
    if(auto_reload)
    {
        timer->is_oneshot = False;
    }
}


boolean start_ttimer(AstralTickTimer timer)
{
    active_ttimer(timer);
    return True;
}

boolean stop_ttimer(AstralTickTimer timer)
{
    deact_ttimer(timer);
    return True;
}

void timer_init()
{
    ttimer_init();
    arch_set_ttimer_timeout(ack_tick_irq);
}